import { http } from "@/utils/http";
import { baseUrlApi } from "@/api/utils";

export type Result = {
  code: number;
  msg?: string;
  data?: Array<any>;
};
/** 获取小区列表 */
export const getResidentialList = (current: number, name: string) => {
  return http.request<Result>(
    "get",
    baseUrlApi(
      "community/residential/list?current=" + current + "&name=" + name
    )
  );
};
/** 根据Id获取小区详情 */
export const getResidentialInfo = (data: any) => {
  return http.request<Result>(
    "get",
    baseUrlApi("community/residential/info/" + data)
  );
};
/** 删除小区 */
export const deleteResidentialById = (data: any) => {
  return http.request<Result>(
    "get",
    baseUrlApi("community/residential/delete/" + data)
  );
};
/** 添加物业 */
export const addResidential = (data: any) => {
  return http.request<Result>("post", baseUrlApi("community/residential/edit"), {
      data
    }
  );
};
/** 根据ID获取物业信息 */
export const getPropertyInfo = (data: any) => {
  return http.request<Result>(
    "get",
    baseUrlApi("community/property/info/" + data)
  );
};
/** 获取物业列表 */
export const getPropertyList = (current?: number, name?: string) => {
  return http.request<Result>(
    "get",
    baseUrlApi("community/property/list?current=" + current + "&name=" + name)
  );
};
/** 删除物业 */
export const deletePropertyById = (data: any) => {
  return http.request<Result>(
    "get",
    baseUrlApi("community/property/delete/" + data)
  );
};
/** 添加物业 */
export const addProperty = (data: any) => {
  return http.request<Result>("post", baseUrlApi("community/property/add"), {
    data
  });
};
/** 获取指定小区的商铺 */
export const getShopsByResidentialId = (data: any) => {
  return http.request<Result>("get", baseUrlApi("property/shops/list/" + data));
};
/** 修改用户身份 */
export const ChangeRole = (data: any) => {
  return http.request<Result>("post", baseUrlApi("community/role/changeRole"), { data });
};
/** 修改物业人员归属的物业*/
export const ChangeProperty = (data?:any)=>{
  return http.request<Result>("post",baseUrlApi("community/property/changeProperty"), { data });
}
